package com.example.android.adapter;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.android.R;
import com.example.android.bean.CarRelease;
import com.example.android.utils.GlideEngine;
import com.example.android.utils.ImageUrlUtil;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class CarReleaseReviewAdapter extends BaseQuickAdapter<CarRelease, BaseViewHolder> {
   public CarReleaseReviewAdapter(List<CarRelease> data){
        super(R.layout.item_car_release_uder_review, data);

    }


    /**
     * 在此方法中设置item数据
     */
    @Override
    protected void convert(@NotNull BaseViewHolder helper, @NotNull CarRelease item) {
        //名称
        TextView userRealName = helper.findView(R.id.name);
        userRealName.setText(item.getUser().getRealName());
        //车牌
        TextView chepai = helper.findView(R.id.textView19);
        chepai.setText(item.getCarInfo().getPlaterNumber());
        //车型
        TextView brand = helper.findView(R.id.textView1);
        brand.setText(item.getCarInfo().getBrand());

        //状态显示
        TextView status = helper.findView(R.id.textView15);
        //地址
        TextView carAddress = helper.findView(R.id.carAddress);
        carAddress.setText(item.getCarInfo().getAddress());

        //预约按钮
        TextView button = helper.findView(R.id.yuyue);

        //主图
        String imagesUrl = ImageUrlUtil.getImagesUrl(item.getCarInfo());
        if (imagesUrl!=null){
            GlideEngine.createGlideEngine().loadGridImage(getContext(), imagesUrl, helper.findView(R.id.profile_image));
        }


        //开始时间
        TextView start = helper.findView(R.id.textView11);
        start.setText(item.getStartTime());
        //结束时间
        TextView end = helper.findView(R.id.textView13);
        end.setText(item.getFinishTimew());
        //判断此数据状态
        if (item.getStatus() == 1) {
            //1待审核-审核中
//            status.setVisibility(View.VISIBLE);
//            status.setText("待审核");
            button.setVisibility(View.VISIBLE);
            button.setText("审核");

        } else if (item.getStatus() == 2) {
            //2 审核通过-可预约
            button.setVisibility(View.VISIBLE);

        } else {
            //3 正在出租中
            status.setText("出租中");
            status.setVisibility(View.VISIBLE);

        }

    }
}
